<?php
namespace app\admin\controller;
use app\admin\model\Member;
use think\Controller;
use think\Request;

class Index extends controller
{
    public function index()
    {
        return $this->fetch();
    }

    public function login()
    {
        $data = input('post.');
        $data['password'] = md5(md5($data['password']));
        if(!captcha_check($data['captcha'])){
            //验证失败
            $this->error('验证码错误');
        }else{
            unset($data['captcha']);
            $member = new Member();
            $res = $member->where($data)->find()->toArray();
            if($res){
                $this->success('登录成功',url('admin/home/index'));
            }else{
                $this->error('帐号密码有误');
            }
        }
    }
    public function test()
    {
        $request = Request::instance();
        echo "当前模块名称是" . $request->module();
        echo "当前控制器名称是" . $request->controller();
        echo "当前操作名称是" . $request->action();
    }
    public function time()
    {
        echo time();
    }
}
